home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
softwareupdate
/
system
/
amigados
/
miscellaneous
/
functions.doc
< prev
next >
Wrap
Text File
|
1996-10-10
|
10KB
|
291 lines
8 MISCELLANEOUS - FUNCTIONS
8.1 QUICK REFERENCE
Here is a complete list of the functions described in this
chapter:
Function Description
-------------------------------------------------------------
Execute() Executes "Shell" commands from C.
IoErr() Returns the last AmigaDOS error message.
SetIoErr() Alters the global dos error variable.
-------------------------------------------------------------
---------------------------------------------------------------
Execute()
ROM library: "dos.library/Execute", (Any Version)
#include <clib/dos_protos.h>
Executes "Shell" commands from C.
Synopsis: ok = Execute( com_str, def_input, def_output );
ok: (LONG) If the command could successfully be
launched TRUE will be returned, else FALSE is
returned.
Please note that the function will not wait for
the executed program to be completed, and the
function can consequently not know if the
executed program finished its task successfully
or failed. The returned value indicates only if
the program was successfully started (launched)
or not.
com_str: (STRPTR) Pointer to a string which contains the
command line you want to have executed. Here are
some examples:
"Dir"
"C:Dir RAM: All"
"C:Copy DH0:Car.doc to DF1:"
"MyPaintProg Flowers.pic"
def_input: (BPTR) Pointer to the "default input handler".
This filed is usually set to NULL, since a
default input handler is usually not needed.
See chapter 6 "Handlers" for more information
about handlers.
def_output: (BPTR) Pointer to the "default output handler".
See chapter 6 "Handlers" for more information
about handlers.
If the program you executed do not use the
default output handler you can set this field
to NULL.
Note! The "run" program must be available in the "C:" directory
if you use Execute() with dos library V34 or earlier.
Here is a simple example on how to use the Execute() function:
/* Store the result code here: */
BOOL ok;
/* A "BCPL" pointer to our "default output */
/* handler": (a Console Window) */
BPTR my_console;
- - -
/* Open a Console Window which will be used as our */
/* default output handler: */
my_console =
Open( "CON:0/0/640/100/Test/CLOSE/WAIT", MODE_NEWFILE );
/* Have we successfully opened the Console Window? */
if( !my_console )
exit( 20 ); /* Exit with an error code: */
/* Execute the "Shell" command "Dir". We do not use */
/* and "input" handler, and the "output" should be */
/* sent to our Console Window. */
ok = Execute( "C:Dir RAM:", NULL, my_console );
/* OK? */
if( ok )
printf( "The \"Shell\" command was successfully executed!\n" );
else
printf( "Error! Could not execute the \"Shell\" command!\n" );
- - -
/* Close the Console Window: */
Close( my_console );
See also: Open(), Close()
---------------------------------------------------------------
IoErr()
ROM library: "dos.library/IoErr", (Any Version)
#include <clib/dos_protos.h>
Returns the last AmigaDOS error message.
Synopsis: error_code = IoErr();
error_code: (LONG) The function will return one of the below
listed error flags: (The flags are defined in
header file "dos/dos.h")
ERROR_NO_FREE_STORE:
Out of memory!
ERROR_TASK_TABLE_FULL:
To many processes running!
ERROR_BAD_TEMPLATE:
Incorrect command line template!
ERROR_BAD_NUMBER:
Incorrect number/value!
ERROR_REQUIRED_ARG_MISSING:
Required arguemnt was not set!
ERROR_KEY_NEEDS_ARG:
The argument after the keyword is missing!
ERROR_TOO_MANY_ARGS:
Too many arguments on the command line!
ERROR_UNMATCHED_QUOTES:
Incorrect number of quotations!
ERROR_LINE_TOO_LONG:
Too long command line!
ERROR_FILE_NOT_OBJECT:
The file can not be found and/or executed
ERROR_INVALID_RESIDENT_LIBRARY:
The AmigaDOS library is too old!
ERROR_NO_DEFAULT_DIR:
There does not exist a default directory!
ERROR_OBJECT_IN_USE:
The object is currently used and is locked!
ERROR_OBJECT_EXISTS:
The object already exist and can not be deleted!
ERROR_DIR_NOT_FOUND:
Unknown directory!
ERROR_OBJECT_NOT_FOUND:
Unknown file or device!
ERROR_BAD_STREAM_NAME:
The string contained invalid commands/parameters!
ERROR_OBJECT_TOO_LARGE:
The object is too big!
ERROR_ACTION_NOT_KNOWN:
Impossible command used on a device!
ERROR_INVALID_COMPONENT_NAME:
Too long name or invalid signs used!
ERROR_INVALID_LOCK:
Invalid type of lock used!
ERROR_OBJECT_WRONG_TYPE:
Incorrect object type used!
ERROR_DISK_NOT_VALIDATED:
The disk has not yet been validated or is damaged!
ERROR_DISK_WRITE_PROTECTED:
The disk is write protected!
ERROR_RENAME_ACROSS_DEVICES:
Can not rename an object to another device!
ERROR_DIRECTORY_NOT_EMPTY:
Can not delete the directory since it is not empty!
ERROR_TOO_MANY_LEVELS:
Too many soft links used!
ERROR_DEVICE_NOT_MOUNTED:
Device not available!
ERROR_SEEK_ERROR:
Tried to move the file cursor outside the file!
ERROR_COMMENT_TOO_BIG:
Too long comment used!
ERROR_DISK_FULL:
The disk is full!
ERROR_DELETE_PROTECTED:
The object is protected from being deleted!
ERROR_WRITE_PROTECTED:
The object is protected from being overwritten
ERROR_READ_PROTECTED:
The object is protected from being read!
ERROR_NOT_A_DOS_DISK:
The disk is not of AmigaDOS format!
ERROR_NO_DISK:
No disk in the drive!
ERROR_NO_MORE_ENTRIES:
No more objects in the directory!
ERROR_IS_SOFT_LINK:
Can not do it on a soft link!
ERROR_OBJECT_LINKED:
The object is linked!
ERROR_BAD_HUNK:
Incorect hunk found!
ERROR_NOT_IMPLEMENTED:
The feature has not been implemented yet!
ERROR_RECORD_NOT_LOCKED:
The record was not locked!
ERROR_LOCK_COLLISION:
Two locks collided!
ERROR_LOCK_TIMEOUT:
The time to get the lock has expired!
ERROR_UNLOCK_ERROR:
Problems with unlocking the object!
ERROR_BUFFER_OVERFLOW:
Some internal buffer was too small!
ERROR_BREAK:
The executin was stopped!
ERROR_NOT_EXECUTABLE:
The file is protected from being executed!
Please note that all dos function does not use the global error
code! You should therefore, of course, only use it when you
have been told that it will work.
Here is a simple example on how to use the IoErr() function:
/* Store the error code here: */
LONG error_code;
- - -
/* Collect the global error code: */
error_code = IoErr();
/* Print the error code: */
printf( "Error code: %d - ", error_code );
/* Examine the error code: */
switch( error_code )
{
case ERROR_NO_FREE_STORE: printf( "Out of memory!\n" ); break;
case ERROR_TASK_TABLE_FULL: printf( "To many processes running!\n" );
break;
/* and so on... */
default:
printf( "Unknown error reported!\n" );
}
See also: SetIoErr()
---------------------------------------------------------------
SetIoErr()
ROM library: "dos.library/SetIoErr", (V36+)
#include <clib/dos_protos.h>
Alters the global dos error variable.
Synopsis: old_value = SetIoErr( new_value );
old_value: (LONG) The function will return the "old" error
value. See "IoErr()" for more information about
the possible error codes.
new_value: (LONG) The new value you want to store in the
global error variable. When you want to "clear"
the variable you should set this field to 0.
Here is a simple example on how to use the SetIoErr() function:
/* Store the "old" error code here: */
LONG old_error_code;
- - -
/* Set the global error variable to 0: */
/* ("Clear" the global error variable) */
old_error_code = SetIoErr( 0 );
/* Print the "old" error code: */
printf( "Old error code: %d\n", old_error_code );
See also: IoErr()
---------------------------------------------------------------